package cn.kgc.mybatis.web.servlet;

import cn.kgc.mybatis.web.dto.DeptPageDTO;
import cn.kgc.mybatis.web.service.DeptService;
import cn.kgc.mybatis.web.service.impl.DeptServiceImpl;
import cn.kgc.mybatis.web.utils.BaseServlet;
import cn.kgc.mybatis.web.utils.ResponseUtil;
import cn.kgc.mybatis.web.vo.ResponseResult;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author 课工场
 * @date 2024/10/31
 * @description
 */
@WebServlet("/dept")
public class DeptServlet extends BaseServlet {


    private DeptService deptService = new DeptServiceImpl();
    /*
    *   搜索分页 和  查询所有分页可以共用接口  method = deptPage
    *
    * */
    protected void deptPage(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        // 获取分页参数
        String page = req.getParameter("page");
        String limit = req.getParameter("limit");

        String deptName = req.getParameter("deptName");
        String local = req.getParameter("local");


        DeptPageDTO deptPageDTO = new DeptPageDTO();
        deptPageDTO.setPage(Integer.valueOf(page));
        deptPageDTO.setLimit(Integer.valueOf(limit));
        deptPageDTO.setDeptName(deptName);
        deptPageDTO.setLocal(local);

        ResponseResult  responseResult =  deptService.deptPage(deptPageDTO);
        ResponseUtil.writeJson(resp,responseResult);


    }
}
